home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / usenet / sources / volume90 / util / gdostool / part01 / gdostool.s < prev    next >
Text File  |  1990-10-14  |  4KB  |  152 lines

  1. ; program to allow user examination and setting of ($0)
  2. ; allows both simulation of the $0='GDOS' phenomena on some a590s and
  3. ; 2091s ( useful for testing code for nil pointer de-references and
  4. ; incorrect use of $0 when it should be #$0
  5. ;
  6. ; also allows clearing of $0, either to remove settings from previous
  7. ; use, or due to the a590/2091 itself
  8.  
  9. forbid        equ    -$084    ; offsets for various exec and int calls
  10. getmsg        equ    -$174    ; saves long includes and compile times
  11. replymsg    equ    -$17a
  12. waitport    equ    -$180
  13. findtask    equ    -$126
  14. autoreq        equ    -$15c
  15. openlib        equ    -$228
  16. closelib    equ    -$19e
  17.  
  18. pr_cli        equ    $0Ac    ; process cli flag offset
  19. pr_msgport    equ    $05c    ; process msgport offset
  20.  
  21. startup:    move.l    $4,a6
  22.         move.l    #0,a1
  23.         jsr    findtask(a6)        ; find ourselves
  24.  
  25.         move.l    d0,a4            ; save our process pointer
  26.  
  27.         move.l    pr_cli(a4),d0
  28.         bne    fromdos            ; was a DOS startup
  29.  
  30.         ; was started from WB
  31.  
  32.         lea    pr_msgport(a4),a0
  33.         jsr    waitport(a6)        ; wait for startup msg
  34.         lea    pr_msgport(a4),a0
  35.         jsr    getmsg(a6)        ; get the wb msg
  36.  
  37.         move.l    d0,wbmsg        ; save pointer to our startup msg
  38.         move.l    #1,wb            ; flag we started from wb
  39.  
  40. fromdos:    move.l    $0,d0
  41.         cmp.l    #$0,d0
  42.         beq    is_zero            ; if $0=0 then req already setup
  43.  
  44.         lea    nzbodytext,a0
  45.         move.l    a0,ctext        ; set so req displays non-zero msg
  46.         bra    _xx
  47.  
  48. is_zero:    lea    zbodytext,a0
  49.         move.l    a0,ctext
  50.  
  51. _xx:        lea    intuiname,a1
  52.         move.l    #0,d0
  53.         move.l    $4,a6
  54.         jsr    openlib(a6)         ; open intuition lib
  55.  
  56.         move.l    d0,a6            ; save ibase
  57.         
  58.         move.l    #0,a0            ; window to display in
  59.         move.l    #bodyitext,a1        ; body text
  60.         move.l    #yesitext,a2         ; postive text
  61.         move.l    #noitext,a3          ; negative text
  62.         move.l    #0,d0            ; pflags
  63.         move.l    #0,d1            ; nflags
  64.         move.l    #640,d2            ; width
  65.         move.l    #50,d3            ; height
  66.         jsr    autoreq(a6)        ; request user confirmation
  67.  
  68.         cmp.l    #0,d0
  69.         beq    cleargdos        ; user selected clear
  70.  
  71. setgdos:    move.l    #"GDOS",$0        ; set $0="GDOS"        
  72.         bra    _n1
  73.  
  74. cleargdos:    move.l    #$0,$0
  75.  
  76. _n1:        move.l    a6,a1            ; close intuition lib
  77.         move.l    $4,a6
  78.         jsr    closelib(A6)
  79.         
  80. exit:        move.l    wb,d0
  81.         cmp.l    #$0,d0            ; was this a CLI invocation
  82.         beq    exit_dos
  83.  
  84.         ; workbench exit
  85.  
  86.         move.l    $4,a6
  87.         jsr    forbid(a6)        ; lock out everyone else
  88.  
  89.         move.l    wbmsg,a1
  90.         jsr    replymsg(a6)        ; reply to Wbstartup msg
  91.  
  92. exit_dos:    move.l    #0,d0            ; return with return code 0
  93.         rts            
  94.  
  95. ;=============================================================
  96.         
  97. wb:        dc.l    0            ; run mode flag 0=dos process 1=wbprocess
  98. wbmsg:        dc.l    0            ; where we save our workbench msg
  99.  
  100. intuiname:    dc.b    "intuition.library",0
  101.  
  102. ; stuff for our autorequester
  103.  
  104. bodyitext:    dc.b    0           ; front pen
  105.         dc.b    1           ; back pen
  106.         dc.b    0           ; draw mode
  107.         dc.w    0           ; leftedge
  108.         dc.w    6           ; topedge
  109.         dc.l    0           ; textattr = default
  110.         dc.l    bodytext1      ; actual text
  111.         dc.l    nbodyitext     ; next
  112.  
  113. nbodyitext:    dc.b    0           ; front pen
  114.         dc.b    1           ; back pen
  115.         dc.b    0           ; draw mode
  116.         dc.w    0           ; leftedge
  117.         dc.w    20           ; topedge
  118.         dc.l    0           ; textattr = default
  119. ctext:        dc.l    0          ; actual text
  120.         dc.l    0         ; next
  121.  
  122.  
  123. yesitext:    dc.b    2        ; front pen
  124.         dc.b    1        ; back pen
  125.         dc.b    0        ; draw mode
  126.         dc.w    4        ; leftedge
  127.         dc.w    4        ; topedge
  128.         dc.l    0        ; textattr = default
  129.         dc.l    yestext        ; actual text
  130.         dc.l    0        ; next
  131.         
  132. noitext:    dc.b    2        ; front pen
  133.         dc.b    1        ; back pen
  134.         dc.b    0        ; draw mode
  135.         dc.w    4        ; leftedge
  136.         dc.w    4        ; topedge
  137.         dc.l    0        ; textattr = default
  138.         dc.l    notext        ; actual text
  139.         dc.l    0        ; next        
  140.  
  141.         ; actual text for our requester
  142.  
  143. bodytext1:    dc.b    "   SetGDOS by J Davis, 08-1990 v1.0 - an aid to hunting nil pointer de-refs",0
  144. zbodytext:    dc.b    "                  Location $0 currently holds a NULL (0) value",0
  145. nzbodytext:    dc.b    "                     Location $0 is currently NON-ZERO",0
  146.  
  147. yestext:    dc.b    "Set $0='GDOS'",0
  148. notext:        dc.b    "Set $0=NULL",0
  149.  
  150.         END
  151.